<?php


namespace app\api\controller\v1;


use app\exception\CategoryException;
use think\annotation\Route;
use app\api\model\Category as CategoryModel;

class Category
{
    /**
     * @Route("v1/category",method="GET",https=0)
     *
     * @throws CategoryException
     */
    public function getAllCategories(): \think\response\Json
    {
       $result = CategoryModel::getCategories();
       if($result->isEmpty()){
           throw new CategoryException();
       }
       return json($result);
    }
}